/**
 * 
 */
package com.duck.base;

import java.util.HashMap;

/**
 * @author Richard Rodriguez
 * 18/9/2014
 */
public abstract class DuckCall {
    
    protected HashMap<String, QuackBehavior> duckSounds;
    
    public DuckCall() {
	super();
	duckSounds = new HashMap<String, QuackBehavior>();
    }

    public void addDuckSound(QuackBehavior behavior){
   	if(!duckSounds.containsKey(behavior))
   	    duckSounds.put(behavior.getSoundType(),behavior);
       }

       public void removeDuckSound(String sound){
   	if(duckSounds.containsKey(sound))
   	    duckSounds.remove(sound);
       }
       
       public void changeBehavior(String soundType, QuackBehavior sound){
   	if(duckSounds.containsKey(soundType)){
   	    removeDuckSound(soundType);
   	    addDuckSound(sound);
   	}
       }
       
       
       public void makeDuckSound(String soundType){
   	 QuackBehavior behavior = duckSounds.get(soundType);
   	 behavior.runBehavior();
       }
}
